package com.ymatou.iapi.csim.testcase;

import java.util.Calendar;
import java.util.Date;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.GetMessageListCSBean;
import com.ymatou.iapi.csim.parameter.OpenSessionBean;
import com.ymatou.iapi.csim.service.GetMessageListCSCall;
import com.ymatou.iapi.csim.service.GetMessageListCall;
import com.ymatou.iapi.csim.service.OpenSessionCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_cssession;
import com.ymttest.database.sqlwapper.CSIM.ymt_cssessionWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_onlinecsWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;
/**
*获取消息列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetMessageListCS{
	private static GetMessageListCSBean bean;
	private static GetMessageListCSCall call;
	private CsimCallService service=new CsimCallService();
	private Integer customerId=Integer.parseInt(EnvSetup.getData("customerId").toString());
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private Integer userId=Integer.parseInt(EnvSetup.getData("userId_IM").toString());
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取消息列表");
	}

	@Before
	public void caseUp() {
		bean=new GetMessageListCSBean();
		call=new GetMessageListCSCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListCS_1() {
		Logger.start(true,"获取消息列表");
		try {
			//查询是否有在线客服 1，2
    		service.getOnlineCS();
    		//打开会话
    		ymt_cssession csSession=service.getOpenSession(csId,userId);
    		
			Date dNow = new Date(); // 当前时间
			Date date = new Date();
			Calendar calendar1 = Calendar.getInstance(); // 得到日历
			calendar1.setTime(dNow);// 把当前时间赋给日历
			calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
			date = calendar1.getTime(); // 得到前一天的时间

			bean.setFromUserId(customerId);
            bean.setToUserId(userId);
            bean.setIsNew(true);
            bean.setTimeline(date);
            bean.setLongTimeline(date.getTime());
            bean.setMessageCount(1000);
            bean.setSessionNumber(csSession.getSessionNumber());
            bean.setCallType(1);
            
			call.setData(bean);
			call.callService();				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}